open(GEND,"../mesa6814_protein_race.csv") or die "no file exists /mesa6814_protein_race.csv\n";
$line=<GEND>;
while(<GEND>)
{
	chomp($_);
	@array=split(",",$_);
	$gender{$array[0]}=$array[3];
	$gender{$array[0]}=~ s/0/2/g;
	$race{$array[0]}=$array[2];
	 #print "$array[0] $gender{$array[0]} $race{$array[0]}\n";
}
open(BUFF,"AFFY_IBC_merged_custom_exome.tfam");
open(WRBUFF,">AFFY_IBC_merged_custom_exome_updated.tfam");
undef(@array);
while(<BUFF>)
{
	@array=split(" ",$_);
	#print "$array[1]\n";
	if(exists($gender{$array[1]}) && exists($race{$array[1]}) && $gender{$array[1]} =~ m/\w/ && $race{$array[1]} =~ m/\w/)
	{
		#$array[4]=$gender{$array[0]};
		#$array[5]=$race{$array[0]};
		#$_ = join(" ",@array);
		if($gender{$array[1]} eq "")
		{
			$gender{$array[1]} =-9;
			$race{$array[1]} = -9;
		}
		print WRBUFF $array[0]." ".$array[1]." ".'0'." ".'0'." ".$gender{$array[1]}." ".$race{$array[1]}."\n";
		#print WRBUFF $_."\n";	
	}
	else
	{
		die "no info $array[1]\n";
	}	
}
close(BUFF);
close(WRBUFF);
